package it.polimi.TravelDream.web.beans;

import it.polimi.TravelDream.ejb.dtos.*;
import it.polimi.TravelDream.ejb.eaos.UserMgr;


import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;


	@ManagedBean(name="registerBean")
	@RequestScoped
	public class RegisterBean {
		
		@EJB
		private UserMgr userMgr;
		private AddressDTO address;
		private UserDTO user;
		
		public RegisterBean() {
			user = new UserDTO();
			address = new AddressDTO();
		}
		public UserDTO getUser() {
			return user;
		}

		public void setUser(UserDTO user) {
			this.user = user;
		}
		
		public AddressDTO getAddress() {
			return address;
		}
		
		public void setAddress(AddressDTO address) {
			this.address = address;
		}
		
		public String register() {
			userMgr.save(user,address);
			return "home?faces-redirect=true";
		}
}
